package com.sm.healthy.ui.fragment

import android.content.Context
import android.os.Bundle
import android.view.View
import androidx.fragment.app.Fragment
import com.sm.healthy.R
import com.sm.healthy.base.BaseFragment
import com.sm.healthy.databinding.FragmentHomeBinding
import com.sm.healthy.model.MainViewModel
import kotlinx.android.synthetic.main.activity_main.*
import kotlinx.android.synthetic.main.fragment_home.*
import kotlinx.android.synthetic.main.title_layout.*
import me.hgj.jetpackmvvm.ext.nav
import me.hgj.jetpackmvvm.ext.navigateAction

// TODO: Rename parameter arguments, choose names that match
// the fragment initialization parameters, e.g. ARG_ITEM_NUMBER
private const val ARG_PARAM1 = "param1"
private const val ARG_PARAM2 = "param2"

/**
 * A simple [Fragment] subclass.
 * Use the [HomeFragment.newInstance] factory method to
 * create an instance of this fragment.
 */
class HomeFragment : BaseFragment<MainViewModel, FragmentHomeBinding>() {
    override fun layoutId(): Int {
        return R.layout.fragment_home
    }

    override fun initView(savedInstanceState: Bundle?) {
//        tv_blood_pressure.setOnClickListener {
//            nav().navigateAction(R.id.action_homeFragment_to_bloodoxygenFragment)
//        }
        mDatabind.click = Click()
        iv_question.visibility = View.GONE
        iv_back.visibility = View.GONE
    }

    override fun onResume() {
        super.onResume()
        rb_home?.isChecked = true
    }

    override fun onAttach(context: Context) {
        super.onAttach(context)
        rb_home?.isChecked = true
    }

    inner class Click {
        fun historyData() {
            nav().navigateAction(R.id.action_homeFragment_to_historyDataFragment)
        }

        fun userCenter() {
            nav().navigateAction(R.id.action_homeFragment_to_userCenterListFragment)
        }

        fun bloodPressure() {
            nav().navigateAction(R.id.action_homeFragment_to_bloodoxygenFragment)
        }

        fun bloodOxygen() {
            nav().navigateAction(R.id.action_homeFragment_to_bloodPressureMeasurementFragment)
        }

        fun bloodSugar() {
            nav().navigateAction(R.id.action_homeFragment_to_bloodGlucoseMeasurementFragment)
        }

        fun ecgMeasurement() {
            nav().navigateAction(R.id.action_homeFragment_to_ecgMeasurementFragment)
        }

        fun fetalHeart() {
            nav().navigateAction(R.id.action_homeFragment_to_fetalHeartMFragment)
        }

        fun temperature() {
            nav().navigateAction(R.id.action_homeFragment_to_temperatureMFragment)
        }
    }
}
